<template>
  <div class="index">
    <el-container>
      <el-header height="68px">
        <m-header></m-header>
      </el-header>
      <el-container>
        <el-aside width="200px">
          <m-aside></m-aside>
        </el-aside>
        <el-main>
          <div class="main">
            <div class="header-top">
              <el-breadcrumb separator-class="el-icon-arrow-right">
                <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
                <el-breadcrumb-item>投递信息管理</el-breadcrumb-item>
              </el-breadcrumb>
              <h2 class="title">投递信息管理</h2>
            </div>
            <div class="row">
              <el-form :inline="true" :model="formInline"  class="demo-form-inline">
                <div class="water">

                  <span class="waterTime">投递时间：</span>
                  <el-date-picker
                    v-model="formInline.time"
                    type="daterange"
                    range-separator="至"
                    start-placeholder="开始日期"
                    end-placeholder="结束日期">
                  </el-date-picker>
                </div>

                <el-form-item label="状态：">
                  <el-select v-model="formInline.status" >
                    <el-option label="已报名" value="10"></el-option>
                    <el-option label="已通过" value="20"></el-option>
                    <el-option label="已工作" value="30"></el-option>
                  </el-select>
                </el-form-item>
                
                
                <el-form-item>
                  <el-button type="primary" @click="onSubmit">搜索</el-button>
                </el-form-item>
              </el-form>

              <el-table
                :data="tableData"
                border
                :cell-style="{'text-align':'center'}"
                :header-cell-style="{
                  'background-color': '#f5f5f5',
                  'color':'#555',
                  'text-align':'center'
                }"
                style="width: 100%">
                <el-table-column
                  prop="listTitle"
                  label="投递职位">
                </el-table-column>
                <el-table-column
                  prop="userName"
                  label="姓名">
                </el-table-column>
                <el-table-column
                  prop="userPhoneNumber"
                  label="联系方式">
                </el-table-column>
                <el-table-column
                  prop="orderStatus"
                  label="状态">
                  <template slot-scope="scope">
                    <el-button @click="statusClick(scope.row)" type="text" size="small" v-if="scope.row.orderStatus == '10'">已报名</el-button>
                    <el-button @click="statusClick(scope.row)" type="text" size="small" v-if="scope.row.orderStatus == '20'">已通过</el-button>
                    <el-button @click="statusClick(scope.row)" type="text" size="small" v-if="scope.row.orderStatus == '30'">已工作</el-button>
                    <el-button @click="statusClick(scope.row)" type="text" size="small" v-if="scope.row.orderStatus == '40'">已取消</el-button>
                  </template>
                </el-table-column>

                <el-table-column
                  prop="orderCreateDate"
                  label="投递">
                </el-table-column>
                <el-table-column
                  label="操作"
                  width="200">
                  <template slot-scope="scope">
                    <el-button @click="checkClick(scope.row)" type="text" >查看简历</el-button>
                  </template>
                </el-table-column>
                
              </el-table>
              <div class="block">
                <el-pagination
                  @size-change="handleSizeChange"
                  @current-change="handleCurrentChange"
                  :current-page="currentPage"
                  :page-sizes="[20, 50, 100]"
                  :page-size="pagesize"
                  layout="total, sizes, prev, pager, next, jumper"
                  :total="total">
                </el-pagination>
              </div>

              <el-dialog
                :visible.sync="dialogVisible"
                :close-on-click-modal=true
                custom-class="diaself"
                center
                top='30vh'
                width="35%">
                <el-form :model="ruleForm"   label-width="100px" class="demo-ruleForm">
                  <el-form-item label="投递职位" prop="listTitle" >
                    <span >{{ruleForm.listTitle}}</span>
                  </el-form-item>
                  <el-form-item label="投递者姓名" prop="userName" >
                    <span >{{ruleForm.userName}}</span>
                  </el-form-item>
                  <el-form-item label="联系方式" prop="userPhoneNumber" >
                    <el-input v-model="ruleForm.userPhoneNumber"></el-input>
                  </el-form-item>

                  <el-form-item label="状态" prop="orderStatus" >
                    <el-radio-group v-model="ruleForm.orderStatus">
                      <el-radio v-model="ruleForm.orderStatus" label="10" >已报名</el-radio>
                      <el-radio v-model="ruleForm.orderStatus" label="20" >已通过</el-radio>
                      <el-radio v-model="ruleForm.orderStatus" label="30" >已工作</el-radio>
                      <el-radio v-model="ruleForm.orderStatus" label="40" >已取消</el-radio>
                    </el-radio-group>
                  </el-form-item>
    
                  
                  <el-form-item>
                    <el-button type="primary" @click="submitForm(ruleForm)">提交</el-button>

                  </el-form-item>
                </el-form>

              </el-dialog>
              <el-dialog
                :visible.sync="dialogVisible1"
                :close-on-click-modal=true
                custom-class="diaself"
                center
                top='30vh'
                width="30%">
                <div class="box">
                  <div class="wrap">
                    <div class="title">
                      <span class="kuai"></span>
                      <span>基本信息</span>
                    </div>
                    <div class="content">
                      <span>姓名：</span>
                      <span>{{resume.name}}</span>
                      <span>{{resume.age}}岁</span>
                      <span  v-if="resume.sex == 'M'">男</span>
                      <span  v-else-if="resume.sex == 'F'">女</span>
                    </div>
                  </div>
                  <div class="wrap">
                    <div class="title">
                      <span class="kuai"></span>
                      <span>教育背景</span>
                    </div>
                    <div class="content">
                      <span>毕业年份：</span>
                      <span>{{resume.biyeYear}}</span>
                      <span>学历：</span>
                      <span v-if="resume.xueli == 1">大专以下</span>
                      <span v-else-if="resume.xueli == 2">大专</span>
                      <span v-else-if="resume.xueli == 3">本科</span>
                      <span v-else-if="resume.xueli == 4">研究生</span>
                      <span v-else-if="resume.xueli == 5">博士</span>
                      <span v-else-if="resume.xueli == 6">博士以上</span>
                    </div>
                    <div class="content">
                      <span>学校名称：</span>
                      <span>{{resume.xuexiao}}</span>

                    </div>
                  </div>
                  <div class="wrap">
                    <div class="title">
                      <span class="kuai"></span>
                      <span>工作经历</span>
                    </div>
                    <div class="content">
                      <textarea  cols="40" rows="4" :value="resume.workExperience"></textarea>
                    </div>
                  </div>
                  <div class="wrap">
                    <div class="title">
                      <span class="kuai"></span>
                      <span>自我评价</span>
                    </div>
                    <div class="content">
                      <textarea  cols="40" rows="4" :value="resume.selfDesc "></textarea>
                    </div>
                  </div>
                </div>
                

              </el-dialog>
    
            </div>

          </div>
        </el-main>
      </el-container>

    </el-container>
  </div>
</template>
<script>
import { getCookie,timeChange,getQueryString } from "./until/index";
function init(){
  this.$ajax.get("bizGetJianzhiOrderList.ashx?token=" +getCookie("token")+'&jianZhiID='+this.formInline.jianZhiID+
        '&status='+this.formInline.status +
        '&dateFrom='+this.startTime +
        '&dateTo='+this.endTime+
        '&pz='+this.pagesize+
        '&pi='+this.currentPage
      )
      .then(res => {
        console.log(res)
        if (res.data.code === "200") {
          var data = res.data.data;
          
          this.total = Number(data.rowCount)
          if(data.rowCount >0){

            this.tableData = data.OrderList;
          }else{
            this.tableData = []
          }
          
        } else {
          this.$message.error(res.data.msg );
        }
      })
      .catch(error => {
        console.log(error);
      });
}
function userDetails(orderID){
  this.$ajax.get("bizGetJianzhiOrderDetail.ashx?token=" +getCookie("token")+
        '&orderID='+orderID
      )
      .then(res => {
        if (res.data.code === "200") {
          var data = res.data.data;
          console.log(data)
          this.ruleForm = data
         
        } else {
          this.$message.error(res.data.msg );
        }
      })
      .catch(error => {
        console.log(error);
      });
}
function userResume(orderID){
  this.$ajax.get("bizGetUserResumeInfo.ashx?token=" +getCookie("token")+
        '&orderID='+orderID
      )
      .then(res => {
        if (res.data.code === "200") {
          var data = res.data.data;
          this.resume = data
         
        } else {
          this.$message.error(res.data.msg );
        }
      })
      .catch(error => {
        console.log(error);
      });
}
function userStatus(orderID,status){
  
  this.$ajax.get("bizChangeJianzhiOrderStatus.ashx?token=" +getCookie("token")+
        '&orderID='+orderID+'&status='+status
      )
      .then(res => {
        if (res.data.code === "200") {
          var data = res.data.data;
        
         this.$message({
            type: 'success',
            message: res.data.msg,
            onClose:function(){

              window.location.reload();
            }
          }); 
        } else {
          this.$message.error(res.data.msg );
        }
      })
      .catch(error => {
        console.log(error);
      });
}
export default {
  data() {
    return {
      pagesize: 20, //每页显示条数
      currentPage: 1, //初始页
      total: 0, //总条数
      startTime:'',
      dialogVisible:false,
      dialogVisible1:false,
      endTime:'',
      ruleForm:{
        orderID:'',
        listTitle:'',
        userName:'',
        userPhoneNumber:'',
        orderStatus:'',
      },
      formInline: {
        jianZhiID:'',
        time:'',//查询时间
        type: '', //红包类型
        status:'',  //红包状态
      },
      resume:{
        name:'',
        sex:'',
        age:'',
        biyeYear:'',
        xueli:'',
        xuexiao:'',
        workExperience:'',
        selfDesc:''
      },//简历
      tableData: [],

    };
  },
  created() {
    if(getQueryString()){
      
      this.formInline.jianZhiID = getQueryString()
    }
    init.call(this)
  },
  methods: {
    onSubmit() {
      if(this.formInline.time){

        this.startTime = timeChange(this.formInline.time[0])
        this.endTime = timeChange(this.formInline.time[1])
      }

      init.call(this)
    },
    handleCurrentChange(num) {
      this.currentPage = num;
      init.call(this)
    },
    handleSizeChange(val) {
      this.pagesize = val;
      init.call(this)
    },
    statusClick(row){
      
      this.$confirm('是否要改变投递状态？', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.dialogVisible = true
          userDetails.call(this,row.orderID)
          
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消退出'
          });          
      });
    },
    submitForm(row){
      this.dialogVisible = false
      userStatus.call(this,row.orderID,row.orderStatus)
    },
    checkClick(row){//查看简历
      this.dialogVisible1 = true
      userResume.call(this,row.orderID)
      
    },
    // redClick(row){
    //   this.$router.push({ path: '/withdrawaDetails'})
    // }
  }
};
</script>
<style scoped>
.index {
  overflow: hidden;
}
.water{margin-right: 20px;display: inline-block}
.waterTime{font-size: 14px;color: #606266;padding: 0 12px 0 0;box-sizing: border-box;}
.el-header {
  background-color: #3a4759;
  color: #fff;
}
.el-aside {
  background-color: #485668;
  color: #333;
  text-align: center;
  line-height: 200px;
  overflow: hidden;
}
.el-main {
  background-color: #f0f2f5;
  color: #333;
  text-align: center;
  height: 100%;
  min-height: 740px
}

.header-top{
  margin: -20px -20px 20px;
  padding: 15px 20px;
  background: #fff;
  
}
.header-top .title{
  margin:15px 0 0;
  font-weight: 600;
  text-align: center;
  font-size: 20px;
}
.row{
  background: #fff;
  padding: 20px 30px;
  text-align: left
}
.block {
  padding: 20px;
}
.message{
  margin-top: 20px;
}
.box .wrap .title{display: flex;align-items: center}
.box .wrap .title .kuai{width: 10px;height: 15px;background: coral;margin-right: 15px}
.box .wrap .content {display: flex;align-items: center;margin-bottom: 10px;margin-top: 10px}
.box .wrap .content span{margin-right: 15px;margin-top: 15px}
.box .wrap .content span:first-child{margin-left: 25px}
.box .wrap .content textarea{margin-top: 5px;margin-left: 25px}
</style>
  